package com.yoouce.patchmng.util;

import org.python.util.PythonInterpreter;

import java.io.IOException;

/**
 * JAVA调用python工具类 Created by Scott.Lee on 15-10-9.
 */
public class PythonUtils
{
    public static void main(String args[])
    {
        Process proc = null;
        try
        {
            proc = Runtime.getRuntime().exec(
                    "/home/administrator/IdeaProjects/patchmng/target/classes/patch.py -u /home/administrator/IdeaProjects/patchmng/target/classes/patch_20151005.tar.gz");
            proc.waitFor();

            StringBuffer sb = new StringBuffer();
            StreamGobbler tp1 = new StreamGobbler(proc.getInputStream());
            StreamGobbler tp2 = new StreamGobbler(proc.getErrorStream());
            tp1.start();
            tp2.start();
            tp1.join();
            tp2.join();
            System.out.println(sb.append(tp1.getResult()));
            System.out.println(sb.append(tp2.getResult()));

        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
        
    }
}
